<script type="text/javascript">		
    $(document).ready(function(){
              	
        //$('#titleAuxPnl').css("display","none");
        
	/*$("#car_type").change(function(){
            var type_id = $(this).val();
            var url = '<?php echo osc_ajax_plugin_url("cars_attributes/ajax.php") . "&typeId="; ?>' + type_id;
            var result = '';
            if(type_id != '') {
                $("#make").attr('disabled',false);
                $.ajax({
                    type: "POST",
                    url: url,
                    dataType: 'json',
                    success: function(data){
                        var length = data.length;
                        if(length > 0) {
                            result += '<option value=""><?php _e("Select a make", 'cars_attributes'); ?></option>';
                            for(key in data) {
                                result += '<option value="' + data[key].pk_i_id + '">' + data[key].s_name + '</option>';
                            }
                            result += '<option value="-1"><?php _e("Others", 'cars_attributes'); ?></option>';
                        } else {
                            result += '<option value=""><?php _e('No results', 'cars_attributes'); ?></option>';
                             $("#makePnl").css("display","none");
                             $("#titleAuxPnl").css("display","inline");
                        }
                        $("#make").html(result);
                    }
                 });
             } else {
                result += '<option value="" selected><?php _e('Select a model', 'cars_attributes'); ?></option>';
                $("#model").attr('disabled',true);
                $("#model").html(result);
				
		result += '<option value="" selected><?php _e('Select a make', 'cars_attributes'); ?></option>';
                $("#make").attr('disabled',true);
                $("#make").html(result);
             }
        });*/
		
        $("#make").change(function(){
            var make_id = $(this).val();
                     
			
            var url = '<?php echo osc_ajax_plugin_url('cars_attributes/ajax.php') . '&makeId='; ?>' + make_id;
            var result = '';
            if(make_id != '') {
                $("#model").attr('disabled',false);
                $.ajax({
                    type: "POST",
                    url: url,
                    dataType: 'json',
                    success: function(data){
                        var length = data.length;
                        if(length > 0) {
                            result += '<option value="" selected><?php _e('Select a model', 'cars_attributes'); ?></option>';
                            for(key in data) {
                                result += '<option value="' + data[key].pk_i_id + '">' + data[key].s_name + '</option>';
                            }
                            result += '<option value="-1"><?php _e("Others", 'cars_attributes'); ?></option>';
                            
                            $("#modelPnl").css("display","");         
                            $("#titleAuxPnl").css("display","none");
                            //validar model y no titleAux
                            
                            
                        } else {
                            result += '<option value=""><?php _e('No results', 'cars_attributes'); ?></option>';
                                                                         
                            $("#titleAuxPnl").css("display","");
                            $("#modelPnl").css("display","none");
                            //validar titleAux y no model
                        }
                        $("#model").html(result);
                    }
                 });                
                
                 
             } else {
                result += '<option value="" selected><?php _e('Select a model', 'cars_attributes'); ?></option>';
                $("#model").attr('disabled',true);
                $("#model").html(result);
             }
             
            if(make_id==-1)
            {
                 $("#MakeModelLbl").css("display", "");
                 $("#ModelLbl").css("display", "none");
            }
            else
            {
                $("#MakeModelLbl").css("display", "none");
                $("#ModelLbl").css("display", "");   
            }  
        });
        
        $("#model").change(function(){
        
            if($(this).val() == -1)
            {
                 $("#MakeModelLbl").css("display", "none");
                 $("#ModelLbl").css("display", "");
                 $("#titleAuxPnl").css("display","");
            }        
            else
            {
                 $("#titleAuxPnl").css("display","none");    
            }
        });
                
       numericInput('mileage');
       numericInput('payload');
       numericInput('weight');
       numericInput('power');
       
    });
    
 

</script>

<div>
    <div id="makePnl" >
        <?php
            if( Session::newInstance()->_getForm('pc_make') != '' ) {
                $detail['fk_i_make_id'] = Session::newInstance()->_getForm('pc_make');
            }
        ?>
	<div class="clearfix">
        <label><?php _e('Make', 'cars_attributes'); ?>  <i class="icon-info-sign" title="<?php _e('Select your vehicle make here', 'cars_attributes'); ?>"></i></label>
		<div class="input" id="makeInput">
			<select name="make" id="make" >
				<option value=""><?php _e('Select a make', 'cars_attributes'); ?></option>
				<?php foreach($makes as $a){ 
                                 $mkId = @$detail['fk_i_make_id'];   
                                 if ($mkId == null) $mkId = -1;
                                ?>
                                
				<option value="<?php echo $a['pk_i_id']; ?>" <?php if(@$detail['fk_i_make_id'] == $a['pk_i_id']) { echo 'selected'; } ?>><?php echo $a['s_name']; ?></option>
				<?php } ?>
                                <option value="-1" <?php if($mkId == -1) { echo 'selected'; } ?>><?php _e('Others', 'cars_attributes'); ?></option>
			</select>
			<span id="makeVal" class="field-validation-valid" data-valmsg-replace="false" data-valmsg-for="make"><?php _e('Select your vehicle make here', 'cars_attributes'); ?></span>
		</div>
		</div>
    </div>
    <div>
        <?php
            if( Session::newInstance()->_getForm('pc_model') != '' ) {
                $detail['fk_i_model_id'] = Session::newInstance()->_getForm('pc_model');
            }
        ?>
    <div class="clearfix" id="modelPnl" 
          <?php if(count($models) <=0) echo "style='display:none;'"; ?>>
        <label><?php _e('Model', 'cars_attributes'); ?> <i class="icon-info-sign" title="<?php _e('Select your vehicle model here', 'cars_attributes'); ?>"></i></label>
		
		<div class="input" id="modelInput">
			<select name="model" id="model" <?php if(@$detail['fk_i_model_id'] == '') { echo 'disabled="disabled"'; } ?>>
				<option value="" selected><?php _e('Select a model', 'cars_attributes'); ?></option>
				<?php foreach($models as $a) { 
                                    $mdId = @$detail['fk_i_model_id'];   
                                 if ($mdId == null) $mdId = -1;?>
				<option value="<?php echo $a['pk_i_id']; ?>" <?php if(@$detail['fk_i_model_id'] == $a['pk_i_id']) { echo 'selected'; } ?>><?php echo $a['s_name']; ?></option>
				<?php } ?>
                                 <option value="-1" <?php if($mdId == -1) { echo 'selected'; } ?>><?php _e('Others', 'cars_attributes'); ?></option>
			</select>
			<span id="modelVal" class="field-validation-valid" data-valmsg-replace="false" data-valmsg-for="model"><?php _e('Select your vehicle model here', 'cars_attributes'); ?></span>		
		</div>
		<span class="help-block" style="margin-left: 150px;">
				<?php _e("<strong>Note:</strong> Select first your vehicle make (up).", 'cars_attributes') ; ?>
		</span>
    </div>
    </div>	
    <div style="display:none;">	
        <?php $locales = osc_get_locales();
        if( Session::newInstance()->_getForm('pc_car_type') != '' ) {
            $detail['fk_vehicle_type_id'] = Session::newInstance()->_getForm('pc_car_type');
        }
        //if(count($locales)==1) {
            $locale = $locales[0]; ?>
            <p>
                <label><?php _e('Car type', 'cars_attributes'); ?></label>
                <select name="car_type" id="car_type">
                    <option value="" selected><?php _e('Select a car type', 'cars_attributes'); ?></option>
                    <?php foreach($car_types[$locale['pk_c_code']] as $k => $v) { ?>
                    <option value="<?php echo  $k; ?>" <?php if(@$detail['fk_vehicle_type_id'] == $k) { echo 'selected'; } ?>><?php echo @$v; ?></option>
                    <?php } ?>
                </select>
            </p>
        <?php //} else { ?>
            <!--<div class="tabber">
            <?php //foreach($locales as $locale) {?>
                <div class="tabbertab">
                    <h2><?php //echo $locale['s_name']; ?></h2>
                    <p>
                        <label><?php //_e('Car type', 'cars_attributes'); ?></label>
                        <select name="car_type" id="car_type">
                            <option value="" selected><?php //_e('Select a car type', 'cars_attributes'); ?></option>
                            <?php //foreach($car_types[$locale['pk_c_code']] as $k => $v) { ?>
                            <option value="<?php //echo  $k; ?>" <?php //if(@$detail['fk_vehicle_type_id'] == $k) { echo 'selected'; } ?>><?php //echo @$v; ?></option>
                            <?php //} ?>
                        </select>
                    </p>
                </div>
            <?php //} ?>
            </div>-->
        <?php //} ?>
    </div>
    <div id="titleAuxPnl"       
          <?php if(@$detail['s_descaux'] == null || @$detail['s_descaux'] == "") echo "style='display:none;'"; ?>>
         <?php
            if( Session::newInstance()->_getForm('pc_descaux') != '' ) {
                $detail['s_descaux'] = Session::newInstance()->_getForm('pc_descaux');
            }
        ?>
        <div  class="clearfix" >
            <label id="MakeModelLbl"
                    <?php if(@$detail['fk_i_make_id']!=null)  echo "style='display:none;'"; ?>><?php _e('Enter Make and Model', 'cars_attributes'); ?> <i class="icon-info-sign" title="<?php _e('Enter vehicle make and model here', 'cars_attributes'); ?>"></i></label>
            <label id="ModelLbl"
                   <?php if(@$detail['fk_i_model_id']==null && @$detail['fk_i_make_id']==null)  echo "style='display:none;'"; ?>><?php _e('Enter Model', 'cars_attributes'); ?> <i class="icon-info-sign" title="<?php _e('Enter vehicle model here', 'cars_attributes'); ?>"></i></label>

            <div class="input" id="titleAuxInput" >
                <input type="text" name="descaux" id="descaux" class="xlarge" value="<?php echo @$detail['s_descaux']; ?>" maxlength="255"/>
            </div>
        </div>
    </div>
    <br/>
    <div>
        <?php
            if( Session::newInstance()->_getForm('pc_registration') != '' ) {
                $detail['i_registration'] = Session::newInstance()->_getForm('pc_registration');
            }
        ?>
		<div class="clearfix">
			<label><?php _e('Registration Year', 'cars_attributes'); ?> <i class="icon-info-sign" title="Fill your vehicle registration year"></i></label></label>
			<div class="input" id="registrationInput">
			<!--<input type="text" name="registration" id="registration" value="<?php //echo @$detail['i_registration']; ?>" size=4 />-->
			<select name="registration" id="registration" style="width:160px;">
			<option value=""><?php _e('Select Year', 'cars_attributes'); ?></option>
			<?php combo_year($detail['i_registration']);	?>
			</select>
			<span id="registrationVal" class="field-validation-valid" data-valmsg-replace="false" data-valmsg-for="make"><?php _e('Select your vehicle registration year', 'cars_attributes'); ?> </span>
			</div>
		</div>
    </div>
    <div id="payloadPnl">
        <?php
            if( Session::newInstance()->_getForm('pc_payload') != '' ) {
                $detail['i_payload'] = Session::newInstance()->_getForm('pc_payload');
            }
        ?>
		<div class="clearfix">
			<label><?php _e('Payload', 'cars_attributes'); ?></label>
			<div class="input">
			<input type="text" name="payload" id="payload" value="<?php echo @$detail['i_payload']; ?>" maxlength="6" /> kg
			</div>
		</div>
        <!--<select name="doors" id="doors">
		<option value=""><?php /*_e('Select num. of doors', 'cars_attributes'); ?></option>
        <?php foreach(range(3, 5) as $n) { ?>
            <option value="<?php echo $n; ?>" <?php if(@$detail['i_doors'] == $n) { echo 'selected'; } ?>><?php echo $n; ?></option>
        <?php } */?>
        </select>-->
    </div>
    <div id="mileagePnl">
        <?php
            if( Session::newInstance()->_getForm('pc_mileage') != '' ) {
                $detail['i_mileage'] = Session::newInstance()->_getForm('pc_mileage');
            }
        ?>
		<div class="clearfix">
			<label><?php _e('Mileage', 'cars_attributes'); ?></label>
			<div class="input">
			<input type="text" name="mileage" id="mileage" value="<?php echo @$detail['i_mileage']; ?>" maxlength="6"/> km
			</div>
		</div>
    </div>
    <div id="weightPnl">
        <?php
            if( Session::newInstance()->_getForm('pc_weight') != '' ) {
                $detail['i_weight'] = Session::newInstance()->_getForm('pc_weight');
            }
        ?>
		<div class="clearfix">
			<label><?php _e('Weight', 'cars_attributes'); ?> </label>
			<div class="input">
			<input type="text" name="weight" id="weight" value="<?php echo @$detail['i_weight']; ?>" maxlength="6"/> kg
			</div>
		</div>
    </div>
     <div id="powerPnl">
        <?php
            if( Session::newInstance()->_getForm('pc_power_unit') != '' ) {
                $detail['e_power_unit'] = Session::newInstance()->_getForm('pc_power_unit');
            }
            if( Session::newInstance()->_getForm('pc_power') != '' ) {
                $detail['i_power'] = Session::newInstance()->_getForm('pc_power');
            }
        ?>
		<div class="clearfix">
			<label><?php _e('Power', 'cars_attributes'); ?></label>
			<div class="input">
			<input type="text" name="power" id="power" value="<?php echo @$detail['i_power']; ?>" maxlength="6"/>
			<select name="power_unit" id="power_unit" style="width:65px">
				<option value="KW" <?php if(@$detail['e_power_unit'] == 'KW') { echo 'selected'; } ?>><?php _e('Kw', 'cars_attributes'); ?></option>
				<option value="CV" <?php if(@$detail['e_power_unit'] == 'CV') { echo 'selected'; } ?>><?php _e('Cv', 'cars_attributes'); ?></option>
				<option value="CH" <?php if(@$detail['e_power_unit'] == 'CH') { echo 'selected'; } ?>><?php _e('Ch', 'cars_attributes'); ?></option>				
				<option value="HP" <?php if(@$detail['e_power_unit'] == 'HP') { echo 'selected'; } ?>><?php _e('Hp', 'cars_attributes'); ?></option>
				<option value="PS" <?php if(@$detail['e_power_unit'] == 'PS') { echo 'selected'; } ?>><?php _e('Ps', 'cars_attributes'); ?></option>
				<option value="PK" <?php if(@$detail['e_power_unit'] == 'PK') { echo 'selected'; } ?>><?php _e('Pk', 'cars_attributes'); ?></option>
				<option value="CP" <?php if(@$detail['e_power_unit'] == 'CP') { echo 'selected'; } ?>><?php _e('Cp', 'cars_attributes'); ?></option>
			</select>
			</div>
		</div>
    </div>   
    <div id="suspensionPnl">
        <?php
            if( Session::newInstance()->_getForm('pc_suspension') != '' ) {
                $detail['e_suspension'] = Session::newInstance()->_getForm('pc_suspension');
            }
        ?>
		<div class="clearfix">
			<label><?php _e('Suspension', 'cars_attributes'); ?> </label>
			<div class="input">
			<select name="suspension" id="suspension">
				<option value=""><?php _e('Select Suspension', 'cars_attributes'); ?></option>
				<option value="Steel spring" <?php if(@$detail['e_suspension'] == 'Steel spring') { echo 'selected'; } ?>><?php _e('Steel Spring', 'cars_attributes'); ?> </option>
				<option value="Pneumatic" <?php if(@$detail['e_suspension'] == 'Pneumatic') { echo 'selected'; } ?>><?php _e('Pneumatic', 'cars_attributes'); ?> </option>
				<!--<option value=""><?php //_e('Select num. of airbags', 'cars_attributes'); ?></option>
				<?php //foreach(range(1, 8) as $n) { ?>
				<option value="<?php //echo $n; ?>" <?php //if(@$detail['i_num_airbags'] == $n) { echo 'selected'; } ?>><?php //echo $n; ?></option>-->
				<?php //} ?>
			</select>
			</div>
		</div>
    </div>
    <div id="axisPnl">
        <?php
            if( Session::newInstance()->_getForm('pc_axis') != '' ) {
                $detail['e_axis'] = Session::newInstance()->_getForm('pc_axis');
            }
        ?>
		<div class="clearfix">
			<label><?php _e('Axis', 'cars_attributes'); ?> </label>
			<div class="input">
			<select name="axis" id="axis">
				<option value=""><?php _e('Select Axis Config', 'cars_attributes'); ?></option>
				<option value="4x2" <?php if(@$detail['e_axis'] == '4x2') { echo 'selected'; } ?>>4x2</option>
				<option value="4x4" <?php if(@$detail['e_axis'] == '4x4') { echo 'selected'; } ?>>4x4</option>
				<option value="6x2" <?php if(@$detail['e_axis'] == '6x2') { echo 'selected'; } ?>>6x2</option>
				<option value="6x4" <?php if(@$detail['e_axis'] == '6x4') { echo 'selected'; } ?>>6x4</option>
				<option value="8x4" <?php if(@$detail['e_axis'] == '8x4') { echo 'selected'; } ?>>8x4</option>
				<option value="8x8" <?php if(@$detail['e_axis'] == '8x8') { echo 'selected'; } ?>>8x8</option>
			</select>
			</div>
		</div>
    </div>
    <div id="cabPnl">
        <?php if( Session::newInstance()->_getForm('pc_cab') != '' ) {
                $detail['e_cab'] = Session::newInstance()->_getForm('pc_cab');
            }
        ?>
		<div class="clearfix">
			<label><?php _e('Cab', 'cars_attributes'); ?></label>
			<div class="input">
			<select name="cab" id="cab">
				<option value=""><?php _e('Select Cabina Type', 'cars_attributes'); ?></option>
				<option value="cab short" <?php if(@$detail['e_cab'] == 'cab short') { echo 'selected'; } ?>><?php _e('Short', 'cars_attributes'); ?> </option>
				<option value="cab medium" <?php if(@$detail['e_cab'] == 'cab medium') { echo 'selected'; } ?>><?php _e('Medium', 'cars_attributes'); ?> </option>
				<option value="cab long" <?php if(@$detail['e_cab'] == 'cab long') { echo 'selected'; } ?>><?php _e('Long', 'cars_attributes'); ?> </option>
				<option value="megaspace" <?php if(@$detail['e_cab'] == 'megaspace') { echo 'selected'; } ?>><?php _e('Megaspace', 'cars_attributes'); ?> </option>
				<option value="other" <?php if(@$detail['e_cab'] == 'other') { echo 'selected'; } ?>><?php _e('Other', 'cars_attributes'); ?> </option>
			</select>
			</div>
		</div>
    </div>   
    <div id="fuelPnl">
        <?php
            if( Session::newInstance()->_getForm('pc_fuel') != '' ) {
                $detail['e_fuel'] = Session::newInstance()->_getForm('pc_fuel');
            }
        ?>
		<div class="clearfix">
			<label><?php _e('Fuel', 'cars_attributes'); ?></label>
			<div class="input">
			<select name="fuel" id="fuel">
				<option value=""><?php _e('Select Fuel Type', 'cars_attributes'); ?></option>
				<option value="DIESEL" <?php if(@$detail['e_fuel'] == 'DIESEL') { echo 'selected'; } ?>><?php _e('Diesel', 'cars_attributes'); ?></option>
				<option value="GASOLINE" <?php if(@$detail['e_fuel'] == 'GASOLINE') { echo 'selected'; } ?>><?php _e('Gasoline', 'cars_attributes'); ?></option>
				<option value="OTHER" <?php if(@$detail['e_fuel'] == 'OTHER') { echo 'selected'; } ?>><?php _e('Other', 'cars_attributes'); ?></option>
			</select>
			</div>
		</div>
    </div>	
     <div id="seatsPnl">
        <?php
            if( Session::newInstance()->_getForm('pc_seats') != '' ) {
                $detail['i_seats'] = Session::newInstance()->_getForm('pc_seats');
            }
        ?>
		<div class="clearfix">
			<label><?php _e('Seats', 'cars_attributes'); ?></label>
			<div class="input">
			<select name="seats" id="seats">
			<option value=""><?php _e('Select num. of seats', 'cars_attributes'); ?></option>
				<?php foreach(range(1, 17) as $n) { ?>
				<option value="<?php echo $n; ?>" <?php if(@$detail['i_seats'] == $n) { echo 'selected'; } ?>><?php echo $n; ?></option>
				<?php } ?>
			</select>
			</div>
		</div>
    </div>
    <div style="display:none;">
        <?php
            if( Session::newInstance()->_getForm('pc_warranty') != '' ) {
                $detail['b_warranty'] = Session::newInstance()->_getForm('pc_warranty');
            }
        ?>
		<div class="clearfix">
			<span style="margin-left:10px;">
			<input type="checkbox" name="warranty" id="warranty" value="1" <?php if(@$detail['b_warranty'] == 1) { echo 'checked="yes"'; } ?> /> 
			</span>
			<label><?php _e('Warranty', 'cars_attributes'); ?></label>
			
		</div>
    </div>
	
    <div>
        <?php
            if( Session::newInstance()->_getForm('pc_new') != '' ) {
                $detail['b_new'] = Session::newInstance()->_getForm('pc_new');
            }
        ?>
		<div class="clearfix">
			<span style="margin-left:10px;">
			<input type="checkbox" name="new" id="new" value="1" <?php if(@$detail['b_new'] == 1) { echo 'checked="yes"'; } ?> /> 
			</span>
			<label><?php _e('New', 'cars_attributes'); ?></label>
		</div>
    </div>   
	<div style="display:none;">
        <?php
            if( Session::newInstance()->_getForm('pc_seller') != '' ) {
                $detail['e_seller'] = Session::newInstance()->_getForm('pc_seller');
            }
        ?>
		<div class="clearfix">
			<label><?php _e('Seller', 'cars_attributes'); ?></label>
			<div class="input">
			<select name="seller" id="seller">
				<option value="DEALER" <?php if(@$detail['e_seller'] == 'DEALER') { echo 'selected'; } ?>><?php _e('Dealer', 'cars_attributes'); ?></option>
				<option value="OWNER" <?php if(@$detail['e_seller'] == 'OWNER') { echo 'selected'; } ?>><?php _e('Owner', 'cars_attributes'); ?></option>
			</select>
			</div>
		</div>
    </div>
    
</div>
<script type="text/javascript">
    //tabberAutomatic();
</script>
